/**
 * Creater with IntelliJ IDEA.
 * Description:
 * User: 86152
 * Dae: 2022-07-23
 * Time: 20:09
 */

public class demo2 {
    public static class MyRunnable implements Runnable {
        public volatile boolean isQuit = false; 
        @Override
        public void run() {
            while(!isQuit) {
                System.out.println("正在执行");
            }
            System.out.println("进程中断");
        }
    }

    public static void main(String[] args) throws InterruptedException {
        MyRunnable target = new MyRunnable();
        Thread t = new Thread(target);
        t.start();
        Thread.sleep(5000);
        System.out.println("使进程中断");
        target.isQuit=true;
    }

}
